package com.stylefeng.guns.modular.owBackstageMgr.contributeMgr.controller;

import com.stylefeng.guns.core.base.controller.BaseController;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestParam;
import com.stylefeng.guns.modular.owBackstageMgr.contributeMgr.service.IContributionService;

/**
 * 问道我要投稿控制器
 *
 * @author fengshuonan
 * @Date 2018-07-01 18:38:49
 */
@Controller
@RequestMapping("/contributionMgr")
public class ContributionController extends BaseController {

    private String PREFIX = "/contributeMgr/contribution/";

    @Autowired
    private IContributionService contributionService;

    /**
     * 跳转到问道我要投稿首页
     */
    @RequestMapping("")
    public String index() {
        return PREFIX + "contribution.html";
    }


    /**
     * 获取问道我要投稿列表
     */
    @RequestMapping(value = "/list")
    @ResponseBody
    public Object list(String condition) {
        return contributionService.selectList(null);
    }

    /**
     * 删除问道我要投稿
     */
    @RequestMapping(value = "/delete")
    @ResponseBody
    public Object delete(@RequestParam Integer contributionId) {
        contributionService.deleteById(contributionId);
        return SUCCESS_TIP;
    }

    /**
     * 问道我要投稿详情
     */
    @RequestMapping(value = "/detail/{contributionId}")
    @ResponseBody
    public Object detail(@PathVariable("contributionId") Integer contributionId) {
        return contributionService.selectById(contributionId);
    }
}
